package com.hdoit.ares.logical.acti.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.hdoit.ares.logical.acti.dao.IActivityDao;
import com.hdoit.ares.logical.acti.model.Activity;
import com.hdoit.ares.logical.acti.service.IActivityService;
import com.hdoit.ares.logical.share.model.ViewTime;
import com.hdoit.ares.logical.share.service.IViewTimeService;
import com.hdoit.ares.logical.viewmodel.acti.ActivitySearch;
import com.tennetcn.common.dao.base.impl.SuperService;
import com.tennetcn.common.enums.ModelStatus;
import com.tennetcn.common.message.PagerModel;
import com.tennetcn.common.utils.CommonUtils;
/**
 * @author      caochengmeng
 * @email       
 * @createtime  2018年03月10日 16:18:06
 * @comment
 */
@Component
public class ActivityServiceImpl extends SuperService<Activity> implements IActivityService{

	private IActivityDao activityDao;
	public IActivityDao getActivityDao() {
		return activityDao;
	}
	@Resource
	public void setActivityDao(IActivityDao activityDao) {
		this.activityDao = activityDao;
	}

	private IViewTimeService viewTimeService;
	
	public IViewTimeService getViewTimeService() {
		return viewTimeService;
	}
	@Resource
	public void setViewTimeService(IViewTimeService viewTimeService) {
		this.viewTimeService = viewTimeService;
	}
	
	@Override
	public List<Activity> queryListHotActivitys() {
		return activityDao.queryListHotActivitys();
	}
	
	@Override
	public List<Activity> queryListHotActivitys(PagerModel pagerModel,ActivitySearch search) {
		return activityDao.queryListHotActivitys(pagerModel,search);
	}
	
	@Override
	public boolean applyChange(Activity activity) {
		if(super.applyChange(activity)){
			
			if(ModelStatus.add.equals(activity.getModelStatus())){
				
					ViewTime viewTime = new ViewTime();
					viewTime.setId(CommonUtils.getKeyId());
					viewTime.setShareid(activity.getId());
					viewTime.setType("activity");
					viewTime.setViewtimes(0);
					viewTime.setDeleteMark(activity.getDeleteMark());
					return viewTimeService.addModel(viewTime);	
			}
			
			return true;
	}
		
		return false;
	}

}